﻿package com.element 
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	/**
	 * ...
	 * @author zhengzihua
	 */
	public class TopBar extends Sprite
	{
		private var userName:TextField;
		private var userLevel:TextField;
		private var userMoney:TextField;
		public function TopBar() 
		{
			init();
		}
		//布局topBar
		private function init():void {
			userName = createTxt();
			userLevel = createTxt();
			userMoney = createTxt();
			userName.y = 0;
			userLevel.y = 18;
			userMoney.y = 36;
		}
		private function createTxt():TextField {
			var txt:TextField = new TextField();	
			var textFormat:TextFormat = new TextFormat();	
			textFormat.size = 14;
			textFormat.color = 0xffffff;
			txt.selectable = false;
			txt.text = "default";
			txt.defaultTextFormat = textFormat;
			txt.autoSize = TextFieldAutoSize.LEFT;
			txt.x = 88;
			addChild(txt);
			return txt;
		}
		public function showUserInfo(name:String, level:int, money:int):void {
			userName.text = name;
			userLevel.text = String(level);
			userMoney.text = String(money);
		}
		
	}
	
}